package demo03_ScheduledExecutorService;

import java.util.concurrent.*;

/**
 * @author liujun
 * @version 1.0
 * @date 2020/10/26
 * @author—Email liujunfirst@outlook.com
 * @blogURL https://blog.csdn.net/ljfirst
 * @description 使用 ScheduledExecutorService 实现 定时任务
 */
public class demo01 {
    public static void main(String[] args) {
        Runnable r = new Runnable() {
            @Override
            public void run() {
                System.out.println("i am schedule(demo03_ScheduledExecutorService)");
            }
        };
        long start_time = 2;
        long delay_time = 2;
        ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
        service.scheduleAtFixedRate(r, start_time, delay_time, TimeUnit.SECONDS);
    }
}
